package org.bee.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.stereotype.Component;

@Component
public class BeanUtil implements BeanFactoryAware {

    private static BeanFactory beanFactory;
    public static  <T> T  getBean(String beanName, Class<T> tClass){
        return beanFactory.getBean(beanName,tClass);
    }

    public static Object getBean(String beanName){
        return beanFactory.getBean(beanName);
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        BeanUtil.beanFactory=beanFactory;
    }
}
